package daydayup.gateway.api.logger;

import java.util.Map;
import java.util.Map.Entry;

import javax.annotation.Resource;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import daydayup.gateway.api.base.util.logger.Loggable;
import daydayup.gateway.api.base.util.logger.LoggerLevel;

@RequestMapping("/daydayup/")
@RestController
public class LoggerController {

	@Resource
	LoggerService loggerService;
	
	@RequestMapping("/logger")
	@Loggable(method = "testLogger", module = "daydayup.gateway.api.logger", optType = "LIST", level = LoggerLevel.DEBUG)
	public String testLogger() {
		System.out.println("================start===========");
		loggerService.add(1, 2);
		return "SUCCESS";
	}
	
	public static void main (String []args) {
		ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
		Map<String, LoggerService> loggerServiceMap =  ac.getBeansOfType(LoggerService.class);
		System.out.println("spring ==============");
		for (Entry entry : loggerServiceMap.entrySet()) {
			LoggerService loggerService = (LoggerService) entry.getValue();
			loggerService.add(1, 2);
		}
		System.out.println("end++++++++++++++++++++++++++=");
	}
}
